//
//  LSWrongBookCell.m
//  听说弱点强化训练
//
//  Created by 盛超 on 2018/9/9.
//  Copyright © 2018年 盛超. All rights reserved.
//

#import "LSWrongBookCell.h"

@implementation LSWrongBookCell {
    UILabel *_typeLabel;
    UILabel *_timeLabel;
    UILabel *_contentLabel;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        UIImageView *imageView = [[UIImageView alloc] init];
        imageView.image = [UIImage imageNamed:@"LS-题型图标"];
        [self addSubview:imageView];
       // imageView.backgroundColor = [UIColor blueColor];
        [imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(14);
            make.bottom.equalTo(self).offset(-9);
            make.size.mas_equalTo(CGSizeMake(20, 20));
        }];
        
        UILabel *typeLabel = [[UILabel alloc] init];
        _typeLabel = typeLabel;
        _typeLabel.textAlignment = NSTextAlignmentLeft;
        typeLabel.font = FONT(14);
        [self addSubview:typeLabel];
        [typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(imageView.mas_right).offset(5);
            make.centerY.equalTo(imageView);
            make.size.mas_equalTo(CGSizeMake(80, 14));
        }];
        
        UILabel *timeLabel = [[UILabel alloc] init];
        _timeLabel = timeLabel;
        timeLabel.font = FONT(11);
        timeLabel.textAlignment = NSTextAlignmentRight;
        timeLabel.textColor = [UIColor colorWithHex:0x797979];
        [self addSubview:timeLabel];
        [timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-14);
            make.centerY.equalTo(imageView);
            make.size.mas_equalTo(CGSizeMake(200, 11));
        }];
        
        UILabel *line = [[UILabel alloc] init];
        line.backgroundColor = [UIColor colorWithHex:0xdedede];
        [self addSubview:line];
        [line mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(14);
            make.right.equalTo(self).offset(-14);
            make.bottom.equalTo(imageView.mas_top).offset(-9);
            make.height.mas_equalTo(0.5);
        }];
        
        UILabel *contentLabel = [[UILabel alloc] init];
        _contentLabel = contentLabel;
        contentLabel.numberOfLines = 0;
        contentLabel.font = FONT(14);
        [self addSubview:contentLabel];
        [contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(14);
            make.right.equalTo(self).offset(-14);
            make.top.equalTo(self).offset(16);
            make.bottom.equalTo(line.mas_top).offset(-30);
        }];
    }
    return self;
}

- (void)setModel:(LSWrongBookItem *)model {
    _model = model;
    
    if([model.TypeName containsString:@"新"]) {
        _typeLabel.text = [model.TypeName stringByReplacingOccurrencesOfString:@"新" withString:@""];
    } else {
        _typeLabel.text = model.TypeName;
    }
    
   
    _timeLabel.text =  [model.CreateTime transfromTLongTime];;
    NSString *text = [model.QuesBrief handleHtml];
    _contentLabel.attributedText = [text dr_HtmlStringWithFontSize:14];
    _contentLabel.lineBreakMode = NSLineBreakByTruncatingTail;
}

@end
